﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SQLite;
using System.Data;
using System.Text.RegularExpressions;

namespace NFinal
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        private static string connectionString = @"Data Source=|DataDirectory|\Session.db";
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        public string GetIdInSql(string sql)
        {
            string sqlTmp = sql;
            string parttern = @"\s+in\s+@([^@,\s]+)";
            Regex reg = new Regex(parttern);
            MatchCollection mac = reg.Matches(sql);
            if (mac.Count > 0)
            {
                for (int i = 0; i < mac.Count; i++)
                {
                    string name = mac[i].Groups[1].Value;
                    sqlTmp = sqlTmp.Remove(mac[i].Groups[1].Index - 1, mac[i].Groups[1].Length + 1);
                    sqlTmp = sqlTmp.Insert(mac[i].Groups[1].Index - 1, "(\"+String.Join(\",\"," + name + ")+\")");
                }
            }
            return sql;
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            int[] a=new int[1];
            string sql = "select * from a where id in @a";
            string sqlTmp = string.Empty;
            string parttern = @"\s+in\s+@([^@,\s]+)";
            Regex reg = new Regex(parttern);
            MatchCollection mac = reg.Matches(sql);
            if (mac.Count>0)
            {
                for (int i = 0; i < mac.Count; i++)
                { 
                    string name=mac[i].Groups[1].Value;
                    sqlTmp= sql.Remove(mac[i].Groups[1].Index - 1, mac[i].Groups[1].Length + 1);
                    sqlTmp= sqlTmp.Insert(mac[i].Groups[1].Index - 1,"(\"+String.Join(\",\","+name+")+\")");
                }
            }
            sqlTmp +=  "";
            string replace = "(\"+String.Join(\",\",{0})+\")";
            sql = "select * from a where id in (" + String.Join(",", a) + ")";
        //    Oracle.ManagedDataAccess.Client.OracleParameter par = new Oracle.ManagedDataAccess.Client.OracleParameter("", Oracle.ManagedDataAccess.Client.OracleDbType.BFile);
        //    Oracle.ManagedDataAccess.Client.OracleDataReader reader = new Oracle.ManagedDataAccess.Client.OracleDataReader();
        //    reader.GetTimeSpan();
           // NFinal.Session.Session se = new Session.Session(null, new TimeSpan(1, 0, 0));
           // string id= se.SetSession(null,"namea","lucasa");
           //string val= se.GetSession(id,"namea");
           //Response.Write(val);
        }
    }
}